<?xml version="1.0" encoding="UTF-8" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:spring="http://www.springframework.org/tags" version="2.0">
	<jsp:directive.page contentType="text/html; charset=UTF-8"
		pageEncoding="UTF-8" session="true" />
	<jsp:output doctype-root-element="html"
		doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
		omit-xml-declaration="true" />
	<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><spring:message code="page.penaltyList.title" /></title>
<spring:url value="/resources/style.css" var="cssRes"></spring:url>
<link href="${cssRes}" rel="stylesheet" type="text/css" />
</head>
<body>
	<c:import url="header.jsp" />
	<spring:message code="adminpage.button.addPenalty"
		var="buttonAddPenalty" />

	<form action="${pageContext.request.contextPath}/admin/add/penalty"
		method="get">
		<input type="submit" value="${buttonAddPenalty}" />
	</form>
	<br />
	<br />

	<c:if test="${penaltyList ne null}">
		<c:url var="firstUrl" value="/admin/show/bonus/pages/1" />
		<c:url var="lastUrl"
			value="/admin/show/bonus/pages/${penaltyList.totalPages}" />
		<c:url var="prevUrl"
			value="/admin/show/bonus/pages/${currentIndex - 1}" />
		<c:url var="nextUrl"
			value="/admin/show/bonus/pages/${currentIndex + 1}" />

		<TABLE class="center">
			<tr>
				<td><spring:message code="page.penalty.name" /></td>
				<td><spring:message code="page.penalty.amount" /></td>
				<td><spring:message code="page.penalty.description" /></td>

			</tr>
			<c:forEach items="${penaltyList.content}" var="penalty">
				<tr>
					<td><c:out value="${penalty.name}" /></td>
					<td><c:out value="${penalty.amount}"></c:out></td>
					<td><c:out value="${penalty.description}" /></td>
					<spring:message code="adminpage.button.change" var="changeBtn" />
					<c:url value="/admin/update/penalty" var="upadteRequestPenalty" />
					<td><FORM action="${upadteRequestPenalty}" method="post">
							<INPUT type="hidden" name="penaltyId"
								value="${penalty.penaltyId}" /> <INPUT type="submit"
								value="${changeBtn}" />
						</FORM></td>

				</tr>
			</c:forEach>
		</TABLE>

		<c:if test="${penaltyList.totalPages > 1}">
			<div id="pagination">
				<ul id="navlist">
					<c:choose>
						<c:when test="${currentIndex == 1}">
							<li class="disabled"><a href="#">&lt;&lt;</a></li>
							<li class="disabled"><a href="#">&lt;</a></li>
						</c:when>
						<c:otherwise>
							<li><a href="${firstUrl}">&lt;&lt;</a></li>
							<li><a href="${prevUrl}">&lt;</a></li>
						</c:otherwise>
					</c:choose>

					<c:forEach var="i" begin="${beginIndex}" end="${endIndex}">
						<c:url var="pageUrl" value="/admin/show/penalty/pages/${i}" />
						<c:choose>
							<c:when test="${i == currentIndex}">
								<li class="active"><a href="${pageUrl}"><c:out
											value="${i}" /></a></li>
							</c:when>
							<c:otherwise>
								<li><a href="${pageUrl}"><c:out value="${i}" /></a></li>
							</c:otherwise>
						</c:choose>
					</c:forEach>
					<c:choose>
						<c:when test="${currentIndex == penaltyList.totalPages}">
							<li class="disabled"><a href="#">&gt;</a></li>
							<li class="disabled"><a href="#">&gt;&gt;</a></li>
						</c:when>
						<c:otherwise>
							<li><a href="${nextUrl}">&gt;</a></li>
							<li><a href="${lastUrl}">&gt;&gt;</a></li>
						</c:otherwise>
					</c:choose>
				</ul>
			</div>
		</c:if>
	</c:if>
</body>
	</html>
</jsp:root>